package rht

import "encoding/json"

type Resp struct {
	Code int      `json:"code"  xml:"code" yaml:"code" bson:"code" form:"code" query:"code"`
	Msg  string   `json:"msg" xml:"msg" yaml:"msg" bson:"msg" form:"msg" query:"msg"`
	Data RespData `json:"data" xml:"data" yaml:"data" bson:"data" form:"data" query:"data"`
}

func (r Resp) String() string {
	marshal, _ := json.Marshal(&r)
	return string(marshal)
}

type RespData struct {
	Data  any `json:"data" xml:"data" yaml:"data" bson:"data" form:"data" query:"data"`
	Other any `json:"other" xml:"other" yaml:"other" bson:"other" form:"other" query:"other"`
}

func NewResp(code int, msg string, data any, other any) Resp {
	return Resp{
		Code: code,
		Msg:  msg,
		Data: RespData{
			Data:  data,
			Other: other,
		},
	}
}
